<!DOCTYPE html>
<html lang="zh">
<head>
	<title>接口列表</title>
	<script src="${base}/resource/js/jquery-1.9.1.min.js"></script>
	<script src="${base}/resource/interface/code-formatter.js" type="text/javascript"></script>
	<link href="${base}/resource/interface/code-formatter.css" type="text/css" rel="stylesheet"/>
<style>
#sendData {
width: 500px; height: 50px;
}

#rawJson {
width:100%; height: 50px;
}
</style>
<script>
function invoke(){
	$.ajax({
	    url: 'directive.json?'+$('#sendData').val(),
	    type: 'GET',
	    contentType:'application/json; charset=UTF-8',
	    dataType: 'text',
	    success: function (data) {
	    	$('#rawJson').val(data);
	    	process($('#rawJson'),$('.canvas'));
	    }
	});
}
function use(action){
	$('#sendData').val('action='+action);
	if($('input[name=showParamters]').is(':checked')){
		$('#sendData').val($('#sendData').val()+'&showParamters=true');
	}
	$('#buttons').show();
	return false;
}
$.ajax({
	url:'directives.json',type: 'GET',
	contentType:'application/json; charset=UTF-8',
	dataType: 'json',
	success: function (dataList) {
		$(dataList).each(function(index,data){
			$('#interfaes').append(' <a href="javascript:;" onclick="return use(\''+data+'\');">'+data+'</a> ');
		});
	}
});
</script>
</head>
<body>
	<fieldset>
		<legend>接口测试</legend>
		<p>
			地址：directive.json?
			<textarea id="sendData"></textarea>
		</p>
		<p id="buttons" style="display:none"><input type="button" value="发送请求" onclick="invoke()"/></p>
		<p id="interfaes">接口列表：</p>
		<label><input name="showParamters" type="checkbox" checked="checked"/>返回请求参数</label>
	</fieldset>
	<fieldset>
		<legend>返回报文</legend>
		<textarea id="rawJson"></textarea>
		<p><input type="button" value="格式化" onclick="process($('#rawJson'),$('.canvas'))"/></p>
		<div class="canvas"></div>
	</fieldset>
</body>
</html>